#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

// 定义学生结构体
struct Student {
    string name;
    int math;
    int eng;
    int sheji;
    int index; // 用于记录输入顺序

    // 计算总成绩
    int total() const {
        return math + eng + sheji;
    }

    // 计算平均成绩
    double average() const {
        return total() / 3.0;
    }
};

int main() {
    int n;
    cin >> n; // 输入学生人数

    vector<Student> students(n); // 定义学生信息的容器

    // 输入学生信息
    for (int i = 0; i < n; i++) {
        cin >> students[i].name >> students[i].math >> students[i].eng >> students[i].sheji;
        students[i].index = i; // 记录输入顺序
    }

    // 排序：按平均成绩从高到低，若平均成绩相等，按输入顺序排序
    sort(students.begin(), students.end(), [](const Student &a, const Student &b) 
    {
        if (a.average() != b.average()) 
        {
            return a.average() > b.average(); // 平均成绩从高到低
        }
        return a.index < b.index; // 平均成绩相同时按输入顺序排序
    });

    // 输出结果
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << students[i].name << " "
             << students[i].math << " " << students[i].eng << " " << students[i].sheji << endl;
    }

    return 0;
}

sort(stu.begin(), stu.end(), [](const Students &a, const Students &b) {
    if (a.average() != b.average()) {
        return a.average() > b.average(); // 按平均成绩降序
    }
    return a.dex < b.dex; // 平均成绩相等时按输入顺序排序
});





#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

// 学生信息的结构体
struct Student {
    string name; // 学生姓名
    int chinese, math, english; // 三科成绩
};

// 判断两名学生是否为旗鼓相当的对手
bool isRival(const Student &a, const Student &b) {
    return abs(a.chinese - b.chinese) <= 5 &&
           abs(a.math - b.math) <= 5 &&
           abs(a.english - b.english) <= 5 &&
           abs((a.chinese + a.math + a.english) - 
               (b.chinese + b.math + b.english)) <= 10;
}

int main() {
    int n;
    cin >> n;
    vector<Student> students(n);

    // 输入学生信息
    for (int i = 0; i < n; i++) 
    {
        cin >> students[i].name >> students[i].chinese 
            >> students[i].math >> students[i].english;
    }

    // 按名字字典序排序
    sort(students.begin(), students.end(), [](const Student &a, const Student &b) 
    {
        return a.name < b.name;
    });

    // 找旗鼓相当的对手并输出
    vector<pair<string, string>> rivals; // 存储对手组合
    for (int i = 0; i < n; i++) 
    {
        for (int j = i + 1; j < n; j++) 
        {
            if (isRival(students[i], students[j])) 
            {
                rivals.emplace_back(students[i].name, students[j].name);
            }
        }
    }

    // 按字典序输出对手组合
    for (const auto &rival : rivals) 
    {
        cout << rival.first << " " << rival.second << endl;
    }

    return 0;
}





#include <iostream>
#include <algorithm> // 使用 std::gcd
using namespace std;

// 三个数的 gcd
int gcd3(int a, int b, int c) 
{
    return __gcd(__gcd(a, b), c);
}

int main() 
{
    int K;
    cin >> K;

    long long result = 0; // 存储结果
    for (int a = 1; a <= K; ++a) 
    {
        for (int b = 1; b <= K; ++b) 
        {
            for (int c = 1; c <= K; ++c) 
            {
                result += gcd3(a, b, c);
            }
        }
    }

    cout << result << endl;
    return 0;
}

